#include <iostream>

using namespace std;

void printArr(int arr[], int len) {
    for (int i = 0; i < len; i++) {
        cout << arr[i] << " ";
    }
    cout << endl;
}

void swap(int& num1, int& num2) {
    int temp = num1;
    num1 = num2;
    num2 = temp;
}

int main() {

    int arr[] = { 4, 2, 8, 0, 5, 7, 1, 3, 9 };

    int len = sizeof(arr) / sizeof(arr[0]);

    cout << "冒泡排序前:" << endl;
    printArr(arr, len);

    for (int i = 0; i < len - 1; i++) {
        for (int j = 0; j < (len - i) - 1; j++) {
            if (arr[j] > arr[j + 1]) {
                swap(arr[j], arr[j + 1]);
            }
        }
    }

    cout << "冒泡排序后:" << endl;
    printArr(arr, len);

    return 0;
}